package com.nado.iims2.blog.bo.service;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.nado.iims2.blog.dao.service.BannerDAO;
import com.nado.iims2.blog.model.service.Banner;
import com.nado.iims2.blog.model.service.BannerThema;

@Service("BannerBO")
public class BannerBOImpl implements BannerBO {
	/** The log. */
	public static Log log = LogFactory.getLog(BannerBOImpl.class);
	
	/** The banner dao. */
	@Autowired
	private BannerDAO bannerDAO = null;
	
	@Override
	public List<BannerThema> getBannerThemaList() {
		try {
			List<BannerThema> result = new ArrayList<BannerThema>();
			result = bannerDAO.selectBannerThemaList();
			return result;
		} catch (Exception e) {
			log.error(e, e);
			return new ArrayList<BannerThema>();
		}
	}

	@Override
	public List<Banner> getBannerList(int bnnrThmSeq, String progressYn, int offset, int count) {
		try {
			List<Banner> result = new ArrayList<Banner>();
			result = bannerDAO.selectBannerList(bnnrThmSeq, progressYn, offset, count);
			return result;
		} catch (Exception e) {
			log.error(e, e);
			return new ArrayList<Banner>();
		}
	}

	@Override
	public int getBannerListCount(int bnnrThmSeq, String progressYn) {
		try {
			return bannerDAO.selectBannerListCount(bnnrThmSeq, progressYn);
		} catch (Exception e) {
			log.error(e, e);
			return 0;
		}
	}

	@Override
	public Banner getBannerDetail(int bnnrSeq) {
		try {
			Banner result = new Banner();
			result = bannerDAO.selectBannerDetail(bnnrSeq);
			return result;
		} catch (Exception e) {
			log.error(e, e);
			return null;
		}
	}

	@Override
	public List<Banner> getBannerOrderList(int bnnrThmSeq) {
		List<Banner> result = new ArrayList<Banner>();
		try {
			result = bannerDAO.selectBannerOrderList(bnnrThmSeq);
		} catch (Exception e) {
			log.error(e, e);
			return new ArrayList<Banner>();
		}
		return result;
	}

	@Override
	public int getMaxBannerOrder(int bnnrThmSeq) {
		try {
			return bannerDAO.selectMaxBannerOrder(bnnrThmSeq);
		} catch (Exception e) {
			log.error(e, e);
			return 0;
		}
	}

	@Override
	public BannerThema getBannerThemaByNo(int bnnrThmSeq) {
		try {
			BannerThema result = new BannerThema();
			result = bannerDAO.selectBannerThemaByNo(bnnrThmSeq);
			return result;
		} catch (Exception e) {
			log.error(e, e);
			return null;
		}
	}

}
